/*
 * Powered By [leyvi]
 * Since 2014 - 2015
 */


var enFans = {};
var common = require('../../utils/commonUtils');
//db转换成model
enFans.dbConvertModel = function(db){
	var enFans = {}; 
	if(common.isNotBlank(db.fans_id)) enFans.fansId = db.fans_id;	
	if(common.isNotBlank(db.account_code)) enFans.accountCode = db.account_code;	
	if(typeof db.fans_userid != "undefined") enFans.fansUserid = db.fans_userid;
	if(typeof db.fans_openid != "undefined") enFans.fansOpenid = db.fans_openid;
	if(typeof db.fans_name != "undefined") enFans.fansName = db.fans_name;
	if(typeof db.fans_department != "undefined") enFans.fansDepartment = db.fans_department;
	if(common.isNotBlank(db.fans_position)) enFans.fansPosition = db.fans_position;	
	if(typeof db.fans_mobile != "undefined") enFans.fansMobile = db.fans_mobile;
	if(common.isNotBlank(db.fans_gender)) enFans.fansGender = db.fans_gender;	
	if(typeof db.fans_email != "undefined") enFans.fansEmail = db.fans_email;
	if(typeof db.fans_weixinid != "undefined") enFans.fansWeixinid = db.fans_weixinid;
	if(typeof db.fans_avatar != "undefined") enFans.fansAvatar = db.fans_avatar;
	if(common.isNotBlank(db.fans_status)) enFans.fansStatus = db.fans_status;	
	if(typeof db.fans_extattr != "undefined") enFans.fansExtattr = db.fans_extattr;
	if(common.isNotBlank(db.fans_createtime)){
		enFans.fansCreatetime = db.fans_createtime;
		enFans.fansCreatetimeStr = db.fans_createtime.format('yyyy-MM-dd hh:mm');
	} 		
	if(common.isNotBlank(db.fans_updatetime)){
		enFans.fansUpdatetime = db.fans_updatetime;
		enFans.fansUpdatetimeStr = db.fans_updatetime.format('yyyy-MM-dd hh:mm');
	} 		
	return enFans;
};

//model转换成db
enFans.modelConvertDb = function(obj){
	var db = {}; 
	if(common.isNotBlank(obj.fansId)) db.fans_id = obj.fansId;
	if(common.isNotBlank(obj.accountCode)) db.account_code = obj.accountCode;
	if(typeof obj.fansUserid != "undefined") db.fans_userid = obj.fansUserid;
	if(typeof obj.fansOpenid != "undefined") db.fans_openid = obj.fansOpenid;
	if(typeof obj.fansName != "undefined") db.fans_name = obj.fansName;
	if(typeof obj.fansDepartment != "undefined") db.fans_department = obj.fansDepartment;
	if(common.isNotBlank(obj.fansPosition)) db.fans_position = obj.fansPosition;
	if(typeof obj.fansMobile != "undefined") db.fans_mobile = obj.fansMobile;
	if(common.isNotBlank(obj.fansGender)) db.fans_gender = obj.fansGender;
	if(typeof obj.fansEmail != "undefined") db.fans_email = obj.fansEmail;
	if(typeof obj.fansWeixinid != "undefined") db.fans_weixinid = obj.fansWeixinid;
	if(typeof obj.fansAvatar != "undefined") db.fans_avatar = obj.fansAvatar;
	if(common.isNotBlank(obj.fansStatus)) db.fans_status = obj.fansStatus;
	if(typeof obj.fansExtattr != "undefined") db.fans_extattr = obj.fansExtattr;
	if(common.isNotBlank(obj.fansCreatetime)) db.fans_createtime = obj.fansCreatetime;
	if(common.isNotBlank(obj.fansUpdatetime)) db.fans_updatetime = obj.fansUpdatetime;
	return db;
};

enFans.initPostReq = function(req){
	var enFans = {};
	if(req.body.fansId != undefined){
		(typeof req.body.fansId != 'string') ? (enFans.fansId = req.body.fansId) : (enFans.fansId = req.body.fansId.trim());
	}
	if(req.body.accountCode != undefined){
		(typeof req.body.accountCode != 'string') ? (enFans.accountCode = req.body.accountCode) : (enFans.accountCode = req.body.accountCode.trim());
	}
	if(req.body.fansUserid != undefined){
		(typeof req.body.fansUserid != 'string') ? (enFans.fansUserid = req.body.fansUserid) : (enFans.fansUserid = req.body.fansUserid.trim());
	}
	if(req.body.fansOpenid != undefined){
		(typeof req.body.fansOpenid != 'string') ? (enFans.fansOpenid = req.body.fansOpenid) : (enFans.fansOpenid = req.body.fansOpenid.trim());
	}
	if(req.body.fansName != undefined){
		(typeof req.body.fansName != 'string') ? (enFans.fansName = req.body.fansName) : (enFans.fansName = req.body.fansName.trim());
	}
	if(req.body.fansDepartment != undefined){
		(typeof req.body.fansDepartment != 'string') ? (enFans.fansDepartment = req.body.fansDepartment) : (enFans.fansDepartment = req.body.fansDepartment.trim());
	}
	if(req.body.fansPosition != undefined){
		(typeof req.body.fansPosition != 'string') ? (enFans.fansPosition = req.body.fansPosition) : (enFans.fansPosition = req.body.fansPosition.trim());
	}
	if(req.body.fansMobile != undefined){
		(typeof req.body.fansMobile != 'string') ? (enFans.fansMobile = req.body.fansMobile) : (enFans.fansMobile = req.body.fansMobile.trim());
	}
	if(req.body.fansGender != undefined){
		(typeof req.body.fansGender != 'string') ? (enFans.fansGender = req.body.fansGender) : (enFans.fansGender = req.body.fansGender.trim());
	}
	if(req.body.fansEmail != undefined){
		(typeof req.body.fansEmail != 'string') ? (enFans.fansEmail = req.body.fansEmail) : (enFans.fansEmail = req.body.fansEmail.trim());
	}
	if(req.body.fansWeixinid != undefined){
		(typeof req.body.fansWeixinid != 'string') ? (enFans.fansWeixinid = req.body.fansWeixinid) : (enFans.fansWeixinid = req.body.fansWeixinid.trim());
	}
	if(req.body.fansAvatar != undefined){
		(typeof req.body.fansAvatar != 'string') ? (enFans.fansAvatar = req.body.fansAvatar) : (enFans.fansAvatar = req.body.fansAvatar.trim());
	}
	if(req.body.fansStatus != undefined){
		(typeof req.body.fansStatus != 'string') ? (enFans.fansStatus = req.body.fansStatus) : (enFans.fansStatus = req.body.fansStatus.trim());
	}
	if(req.body.fansExtattr != undefined){
		(typeof req.body.fansExtattr != 'string') ? (enFans.fansExtattr = req.body.fansExtattr) : (enFans.fansExtattr = req.body.fansExtattr.trim());
	}
	if(req.body.fansCreatetime != undefined){
		(typeof req.body.fansCreatetime != 'string') ? (enFans.fansCreatetime = req.body.fansCreatetime) : (enFans.fansCreatetime = req.body.fansCreatetime.trim());
	}
	if(req.body.fansUpdatetime != undefined){
		(typeof req.body.fansUpdatetime != 'string') ? (enFans.fansUpdatetime = req.body.fansUpdatetime) : (enFans.fansUpdatetime = req.body.fansUpdatetime.trim());
	}
	return enFans;
};

enFans.initGetReq = function(req){
	var enFans = {};
	if(req.query.fansId != undefined){	
		(typeof req.query.fansId != 'string') ? (enFans.fansId = req.query.fansId) : (enFans.fansId = req.query.fansId.trim());
	}
	if(req.query.accountCode != undefined){	
		(typeof req.query.accountCode != 'string') ? (enFans.accountCode = req.query.accountCode) : (enFans.accountCode = req.query.accountCode.trim());
	}
	if(req.query.fansUserid != undefined){	
		(typeof req.query.fansUserid != 'string') ? (enFans.fansUserid = req.query.fansUserid) : (enFans.fansUserid = req.query.fansUserid.trim());
	}
	if(req.query.fansOpenid != undefined){	
		(typeof req.query.fansOpenid != 'string') ? (enFans.fansOpenid = req.query.fansOpenid) : (enFans.fansOpenid = req.query.fansOpenid.trim());
	}
	if(req.query.fansName != undefined){	
		(typeof req.query.fansName != 'string') ? (enFans.fansName = req.query.fansName) : (enFans.fansName = req.query.fansName.trim());
	}
	if(req.query.fansDepartment != undefined){	
		(typeof req.query.fansDepartment != 'string') ? (enFans.fansDepartment = req.query.fansDepartment) : (enFans.fansDepartment = req.query.fansDepartment.trim());
	}
	if(req.query.fansPosition != undefined){	
		(typeof req.query.fansPosition != 'string') ? (enFans.fansPosition = req.query.fansPosition) : (enFans.fansPosition = req.query.fansPosition.trim());
	}
	if(req.query.fansMobile != undefined){	
		(typeof req.query.fansMobile != 'string') ? (enFans.fansMobile = req.query.fansMobile) : (enFans.fansMobile = req.query.fansMobile.trim());
	}
	if(req.query.fansGender != undefined){	
		(typeof req.query.fansGender != 'string') ? (enFans.fansGender = req.query.fansGender) : (enFans.fansGender = req.query.fansGender.trim());
	}
	if(req.query.fansEmail != undefined){	
		(typeof req.query.fansEmail != 'string') ? (enFans.fansEmail = req.query.fansEmail) : (enFans.fansEmail = req.query.fansEmail.trim());
	}
	if(req.query.fansWeixinid != undefined){	
		(typeof req.query.fansWeixinid != 'string') ? (enFans.fansWeixinid = req.query.fansWeixinid) : (enFans.fansWeixinid = req.query.fansWeixinid.trim());
	}
	if(req.query.fansAvatar != undefined){	
		(typeof req.query.fansAvatar != 'string') ? (enFans.fansAvatar = req.query.fansAvatar) : (enFans.fansAvatar = req.query.fansAvatar.trim());
	}
	if(req.query.fansStatus != undefined){	
		(typeof req.query.fansStatus != 'string') ? (enFans.fansStatus = req.query.fansStatus) : (enFans.fansStatus = req.query.fansStatus.trim());
	}
	if(req.query.fansExtattr != undefined){	
		(typeof req.query.fansExtattr != 'string') ? (enFans.fansExtattr = req.query.fansExtattr) : (enFans.fansExtattr = req.query.fansExtattr.trim());
	}
	if(req.query.fansCreatetime != undefined){	
		(typeof req.query.fansCreatetime != 'string') ? (enFans.fansCreatetime = req.query.fansCreatetime) : (enFans.fansCreatetime = req.query.fansCreatetime.trim());
	}
	if(req.query.fansUpdatetime != undefined){	
		(typeof req.query.fansUpdatetime != 'string') ? (enFans.fansUpdatetime = req.query.fansUpdatetime) : (enFans.fansUpdatetime = req.query.fansUpdatetime.trim());
	}
	return enFans;
};


module.exports = enFans;
